#include "sweFunctions.hpp"
#include "uniMesh.hpp"
#include "field.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>

using Catch::Approx;
using namespace hms;

TEST_CASE( "courantTimeStep: Maximum stable time step" ){
	scalar val { 0.15198 };
	SECTION( "passing values directly" ){
		REQUIRE( courantTimeStep(2.25, 6, Array2s{2, 3}, 4) == Approx(val) );
	}
	SECTION( "Cell+Field overload" ){
		UniMesh mesh {1, 1, 1.5, 1.5};
		Field v { mesh, 2 };
		v.values().colwise() = Array2s{2,3};
		Field d { mesh, 1 };
		d.values() = 4;

		REQUIRE( courantTimeStep(mesh.cell(0,0), v, d) == Approx(val) );
	}
}

TEST_CASE( "chezy: Chezy-coefficient from water depth and Manning's n" ){
	REQUIRE( chezy( 4, 0.025 ) == Approx(50.397) );
}

TEST_CASE( "wavespeed: shallow water wave speed" ){
	REQUIRE( wavespeed(2) == Approx(4.4294) );
}
